package cc.chengheng.acl;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

@SpringBootApplication
//@EnableDiscoveryClient
@MapperScan("cc.chengheng.acl.mapper")
@ComponentScan(basePackages={"cc.chengheng"})
public class ServiceAclApplication {

    public static void main(String[] args) throws IOException {
        SpringApplication.run(ServiceAclApplication.class, args);



       /* Package aPackage = ServiceAclApplication.class.getPackage();
        String name = aPackage.getName().replace(".","/");
        Enumeration<URL> resources = ServiceAclApplication.class.getClassLoader().getResources(
                "cc/chengheng");

        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            String protocol = url.getProtocol(); // 返回file 或 jar

            *//*
             * file:/Users/fengliulin/.m2/repository/org/springframework/boot/
             * spring-boot/2.2.1.RELEASE/spring-boot-2.2.1.RELEASE.jar!/org/springframework/boot
             *//*
            String path = url.getPath();

            String[] split = path.split("!");

            // 去掉file:
            String jarFilePath = split[0].substring(split[0].indexOf("/"));

            // 得到 org/springframework/boot
            String packagePath = split[1].substring(1);

            // 就是通过上面的拆封，得到磁盘上的jar文件所在的绝对路径
            JarFile jarFile = new JarFile(jarFilePath);

            Enumeration<JarEntry> entries = jarFile.entries();

            // 遍历jar里面的东西
            while (entries.hasMoreElements()) {
                JarEntry jarEntry = entries.nextElement();
                String name1 = jarEntry.getName();
                System.out.println(name1);
            }
            System.out.println(url);
        }
        System.out.println();*/
    }

}
